from abc import ABC, abstractmethod

class BaseAdapter(ABC):
    @abstractmethod
    def detect(self, url):
        """检测URL是否属于该平台"""
        pass
    
    @abstractmethod
    def parse(self, html):
        """解析文档内容"""
        pass
    
    @abstractmethod
    def download(self):
        """执行下载操作"""
        pass

    @classmethod
    def factory(cls, url):
        """工厂方法创建适配器"""
        for subclass in cls.__subclasses__():
            if subclass().detect(url):
                return subclass()
        raise ValueError("Unsupported platform")